#pragma once
#include "..\Common\Global.h"

template <typename I,typename O>
class Combinator_Alt : public Combinator<I,O>
{
public:
	Combinator_Alt(Combinator_Node<I,O>& _left,Combinator_Node<I,O>& _right,Combinator_MemoryManager<I,O>* _MM) : left(_left),right(_right),Combinator<I,O>(_MM){}

	virtual O Parser(I& input)
	{
		I temp = input;
		if(O Result = left.Parser(input)) return Result;
		input = temp;
		if(O Result = right.Parser(input)) return Result;
		input = temp;
		O Result(GetMM());
		return Result;
	}
protected:
	Combinator_Node<I,O>& left;
	Combinator_Node<I,O>& right;
};